<template>
  <div class="collect-page">
    <van-nav-bar fixed title="我的收藏" />
    <van-list
      v-model="loading"
      :finished="finished"
      finished-text="没有更多了"
      @load="onLoad"
    >
      <article-item v-for="item in list" :key="item.id" :item="item" />
    </van-list>
  </div>
</template>

<script>
import { collectAndLike } from '@/api/article'
export default {
  name: 'collect-page',
  data() {
    return {
      list: [],
      loading: false,
      finished: false,
      current: 1
    }
  },
  methods: {
    async onLoad() {
      const res = await collectAndLike({
        page: this.current,
        optType: 2
      })
      // console.log(res)
      this.list.push(...res.data.data.rows)
      this.loading = false
      if (this.current >= res.data.data.pageTotal) this.finished = true
      this.current++
    }
  }
}
</script>

<style lang="less" scoped>
.collect-page {
  margin-bottom: 50px;
  margin-top: 44px;
}
</style>
